// jCollapse Plugin for jQuery - Version 0.3
// by Angel Grablev for Enavu Web Development network (enavu.com)
// Dual license under MIT and GPL :) enjoy
/*

To use simply call .jCollapse() on the element you wish like so:
$(".collapse").jCollapse(); 

you can specify the following options:
expand_text = the text that will expend the elements specified
collapse_text = the text that will replace the expand text once the elements have been shown
effect = this will be the effect that will change the way the new element/s show up, available options are: display, slide, fade

*/
(function($){
    $.fn.jCollapse = function(options) {
        var defaults = {
            expand_text: "Expand",
            collapse_text: "Collapse",
			effect: "display"
        };
        var options = $.extend(defaults, options);

        return this.each(function() {
            // object is the selected pagination element list
            var obj = $(this);
            // the expand text
            var expand_text = options.expand_text;
			// set the current element with the expand text no matter what
			obj.html(expand_text);
			// the collapse text
            var collapse_text = options.expand_text;
			// get the element we are collapsing 
			var obj_c = $(obj.attr("rel"));
			obj.click(function(e){
				e.preventDefault();
				if (obj.html() == expand_text) {
					obj.html(options.collapse_text);
					switch(options.effect) {
						case "display":
							obj_c.show();
							break;
						case "fade":
							obj_c.fadeIn("slow");
							break;
						case "slide":
							obj_c.slideDown("slow");
							break;
						default:
							obj_c.show();
					}
				} else {
					obj.html(options.expand_text);
					switch(options.effect) {
						case "display":
							obj_c.hide();
							break;
						case "fade":
							obj_c.fadeOut("slow");
							break;
						case "slide":
							obj_c.slideUp("slow");
							break;
						default:
							obj_c.hide();
					}
				}	
			});
		});
    };
})(jQuery);